
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
  <head>
    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>PostgreSQL specific form fields and widgets &#8212; Django 1.11.22.dev20190603194737 documentation</title>
    <link rel="stylesheet" href="../../../_static/default.css" type="text/css" />
    <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
    <script type="text/javascript" id="documentation_options" data-url_root="../../../" src="../../../_static/documentation_options.js"></script>
    <script type="text/javascript" src="../../../_static/jquery.js"></script>
    <script type="text/javascript" src="../../../_static/underscore.js"></script>
    <script type="text/javascript" src="../../../_static/doctools.js"></script>
    <script type="text/javascript" src="../../../_static/language_data.js"></script>
    <link rel="index" title="Index" href="../../../genindex.html" />
    <link rel="search" title="Search" href="../../../search.html" />
    <link rel="next" title="PostgreSQL specific database functions" href="functions.html" />
    <link rel="prev" title="PostgreSQL specific model fields" href="fields.html" />



 
<script type="text/javascript" src="../../../templatebuiltins.js"></script>
<script type="text/javascript">
(function($) {
    if (!django_template_builtins) {
       // templatebuiltins.js missing, do nothing.
       return;
    }
    $(document).ready(function() {
        // Hyperlink Django template tags and filters
        var base = "../../templates/builtins.html";
        if (base == "#") {
            // Special case for builtins.html itself
            base = "";
        }
        // Tags are keywords, class '.k'
        $("div.highlight\\-html\\+django span.k").each(function(i, elem) {
             var tagname = $(elem).text();
             if ($.inArray(tagname, django_template_builtins.ttags) != -1) {
                 var fragment = tagname.replace(/_/, '-');
                 $(elem).html("<a href='" + base + "#" + fragment + "'>" + tagname + "</a>");
             }
        });
        // Filters are functions, class '.nf'
        $("div.highlight\\-html\\+django span.nf").each(function(i, elem) {
             var filtername = $(elem).text();
             if ($.inArray(filtername, django_template_builtins.tfilters) != -1) {
                 var fragment = filtername.replace(/_/, '-');
                 $(elem).html("<a href='" + base + "#" + fragment + "'>" + filtername + "</a>");
             }
        });
    });
})(jQuery);
</script>


  </head><body>

    <div class="document">
  <div id="custom-doc" class="yui-t6">
    <div id="hd">
      <h1><a href="../../../index.html">Django 1.11.22.dev20190603194737 documentation</a></h1>
      <div id="global-nav">
        <a title="Home page" href="../../../index.html">Home</a>  |
        <a title="Table of contents" href="../../../contents.html">Table of contents</a>  |
        <a title="Global index" href="../../../genindex.html">Index</a>  |
        <a title="Module index" href="../../../py-modindex.html">Modules</a>
      </div>
      <div class="nav">
    &laquo; <a href="fields.html" title="PostgreSQL specific model fields">previous</a>
     |
    <a href="../../index.html" title="API Reference" accesskey="U">up</a>
   |
    <a href="functions.html" title="PostgreSQL specific database functions">next</a> &raquo;</div>
    </div>

    <div id="bd">
      <div id="yui-main">
        <div class="yui-b">
          <div class="yui-g" id="ref-contrib-postgres-forms">
            
  <div class="section" id="s-postgresql-specific-form-fields-and-widgets">
<span id="postgresql-specific-form-fields-and-widgets"></span><h1>PostgreSQL specific form fields and widgets<a class="headerlink" href="#postgresql-specific-form-fields-and-widgets" title="Permalink to this headline">¶</a></h1>
<p>All of these fields and widgets are available from the
<code class="docutils literal notranslate"><span class="pre">django.contrib.postgres.forms</span></code> module.</p>
<div class="section" id="s-fields">
<span id="fields"></span><h2>Fields<a class="headerlink" href="#fields" title="Permalink to this headline">¶</a></h2>
<div class="section" id="s-simplearrayfield">
<span id="simplearrayfield"></span><h3><code class="docutils literal notranslate"><span class="pre">SimpleArrayField</span></code><a class="headerlink" href="#simplearrayfield" title="Permalink to this headline">¶</a></h3>
<dl class="class">
<dt id="django.contrib.postgres.forms.SimpleArrayField">
<em class="property">class </em><code class="descname">SimpleArrayField</code>(<em>base_field</em>, <em>delimiter='</em>, <em>'</em>, <em>max_length=None</em>, <em>min_length=None</em>)<a class="reference internal" href="../../../_modules/django/contrib/postgres/forms/array.html#SimpleArrayField"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#django.contrib.postgres.forms.SimpleArrayField" title="Permalink to this definition">¶</a></dt>
<dd><p>A simple field which maps to an array. It is represented by an HTML
<code class="docutils literal notranslate"><span class="pre">&lt;input&gt;</span></code>.</p>
<dl class="attribute">
<dt id="django.contrib.postgres.forms.SimpleArrayField.base_field">
<code class="descname">base_field</code><a class="headerlink" href="#django.contrib.postgres.forms.SimpleArrayField.base_field" title="Permalink to this definition">¶</a></dt>
<dd><p>This is a required argument.</p>
<p>It specifies the underlying form field for the array. This is not used
to render any HTML, but it is used to process the submitted data and
validate it. For example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">django.contrib.postgres.forms</span> <span class="k">import</span> <span class="n">SimpleArrayField</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">django</span> <span class="k">import</span> <span class="n">forms</span>

<span class="gp">&gt;&gt;&gt; </span><span class="k">class</span> <span class="nc">NumberListForm</span><span class="p">(</span><span class="n">forms</span><span class="o">.</span><span class="n">Form</span><span class="p">):</span>
<span class="gp">... </span>    <span class="n">numbers</span> <span class="o">=</span> <span class="n">SimpleArrayField</span><span class="p">(</span><span class="n">forms</span><span class="o">.</span><span class="n">IntegerField</span><span class="p">())</span>

<span class="gp">&gt;&gt;&gt; </span><span class="n">form</span> <span class="o">=</span> <span class="n">NumberListForm</span><span class="p">({</span><span class="s1">&#39;numbers&#39;</span><span class="p">:</span> <span class="s1">&#39;1,2,3&#39;</span><span class="p">})</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">form</span><span class="o">.</span><span class="n">is_valid</span><span class="p">()</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">form</span><span class="o">.</span><span class="n">cleaned_data</span>
<span class="go">{&#39;numbers&#39;: [1, 2, 3]}</span>

<span class="gp">&gt;&gt;&gt; </span><span class="n">form</span> <span class="o">=</span> <span class="n">NumberListForm</span><span class="p">({</span><span class="s1">&#39;numbers&#39;</span><span class="p">:</span> <span class="s1">&#39;1,2,a&#39;</span><span class="p">})</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">form</span><span class="o">.</span><span class="n">is_valid</span><span class="p">()</span>
<span class="go">False</span>
</pre></div>
</div>
</dd></dl>

<dl class="attribute">
<dt id="django.contrib.postgres.forms.SimpleArrayField.delimiter">
<code class="descname">delimiter</code><a class="headerlink" href="#django.contrib.postgres.forms.SimpleArrayField.delimiter" title="Permalink to this definition">¶</a></dt>
<dd><p>This is an optional argument which defaults to a comma: <code class="docutils literal notranslate"><span class="pre">,</span></code>. This
value is used to split the submitted data. It allows you to chain
<code class="docutils literal notranslate"><span class="pre">SimpleArrayField</span></code> for multidimensional data:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">django.contrib.postgres.forms</span> <span class="k">import</span> <span class="n">SimpleArrayField</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">django</span> <span class="k">import</span> <span class="n">forms</span>

<span class="gp">&gt;&gt;&gt; </span><span class="k">class</span> <span class="nc">GridForm</span><span class="p">(</span><span class="n">forms</span><span class="o">.</span><span class="n">Form</span><span class="p">):</span>
<span class="gp">... </span>    <span class="n">places</span> <span class="o">=</span> <span class="n">SimpleArrayField</span><span class="p">(</span><span class="n">SimpleArrayField</span><span class="p">(</span><span class="n">IntegerField</span><span class="p">()),</span> <span class="n">delimiter</span><span class="o">=</span><span class="s1">&#39;|&#39;</span><span class="p">)</span>

<span class="gp">&gt;&gt;&gt; </span><span class="n">form</span> <span class="o">=</span> <span class="n">GridForm</span><span class="p">({</span><span class="s1">&#39;places&#39;</span><span class="p">:</span> <span class="s1">&#39;1,2|2,1|4,3&#39;</span><span class="p">})</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">form</span><span class="o">.</span><span class="n">is_valid</span><span class="p">()</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">form</span><span class="o">.</span><span class="n">cleaned_data</span>
<span class="go">{&#39;places&#39;: [[1, 2], [2, 1], [4, 3]]}</span>
</pre></div>
</div>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">The field does not support escaping of the delimiter, so be careful
in cases where the delimiter is a valid character in the underlying
field. The delimiter does not need to be only one character.</p>
</div>
</dd></dl>

<dl class="attribute">
<dt id="django.contrib.postgres.forms.SimpleArrayField.max_length">
<code class="descname">max_length</code><a class="headerlink" href="#django.contrib.postgres.forms.SimpleArrayField.max_length" title="Permalink to this definition">¶</a></dt>
<dd><p>This is an optional argument which validates that the array does not
exceed the stated length.</p>
</dd></dl>

<dl class="attribute">
<dt id="django.contrib.postgres.forms.SimpleArrayField.min_length">
<code class="descname">min_length</code><a class="headerlink" href="#django.contrib.postgres.forms.SimpleArrayField.min_length" title="Permalink to this definition">¶</a></dt>
<dd><p>This is an optional argument which validates that the array reaches at
least the stated length.</p>
</dd></dl>

<div class="admonition-user-friendly-forms admonition">
<p class="first admonition-title">User friendly forms</p>
<p class="last"><code class="docutils literal notranslate"><span class="pre">SimpleArrayField</span></code> is not particularly user friendly in most cases,
however it is a useful way to format data from a client-side widget for
submission to the server.</p>
</div>
</dd></dl>

</div>
<div class="section" id="s-splitarrayfield">
<span id="splitarrayfield"></span><h3><code class="docutils literal notranslate"><span class="pre">SplitArrayField</span></code><a class="headerlink" href="#splitarrayfield" title="Permalink to this headline">¶</a></h3>
<dl class="class">
<dt id="django.contrib.postgres.forms.SplitArrayField">
<em class="property">class </em><code class="descname">SplitArrayField</code>(<em>base_field</em>, <em>size</em>, <em>remove_trailing_nulls=False</em>)<a class="reference internal" href="../../../_modules/django/contrib/postgres/forms/array.html#SplitArrayField"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#django.contrib.postgres.forms.SplitArrayField" title="Permalink to this definition">¶</a></dt>
<dd><p>This field handles arrays by reproducing the underlying field a fixed
number of times.</p>
<dl class="attribute">
<dt id="django.contrib.postgres.forms.SplitArrayField.base_field">
<code class="descname">base_field</code><a class="headerlink" href="#django.contrib.postgres.forms.SplitArrayField.base_field" title="Permalink to this definition">¶</a></dt>
<dd><p>This is a required argument. It specifies the form field to be
repeated.</p>
</dd></dl>

<dl class="attribute">
<dt id="django.contrib.postgres.forms.SplitArrayField.size">
<code class="descname">size</code><a class="headerlink" href="#django.contrib.postgres.forms.SplitArrayField.size" title="Permalink to this definition">¶</a></dt>
<dd><p>This is the fixed number of times the underlying field will be used.</p>
</dd></dl>

<dl class="attribute">
<dt id="django.contrib.postgres.forms.SplitArrayField.remove_trailing_nulls">
<code class="descname">remove_trailing_nulls</code><a class="headerlink" href="#django.contrib.postgres.forms.SplitArrayField.remove_trailing_nulls" title="Permalink to this definition">¶</a></dt>
<dd><p>By default, this is set to <code class="docutils literal notranslate"><span class="pre">False</span></code>. When <code class="docutils literal notranslate"><span class="pre">False</span></code>, each value from
the repeated fields is stored. When set to <code class="docutils literal notranslate"><span class="pre">True</span></code>, any trailing
values which are blank will be stripped from the result. If the
underlying field has <code class="docutils literal notranslate"><span class="pre">required=True</span></code>, but <code class="docutils literal notranslate"><span class="pre">remove_trailing_nulls</span></code>
is <code class="docutils literal notranslate"><span class="pre">True</span></code>, then null values are only allowed at the end, and will be
stripped.</p>
<p>Some examples:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">SplitArrayField</span><span class="p">(</span><span class="n">IntegerField</span><span class="p">(</span><span class="n">required</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> <span class="n">size</span><span class="o">=</span><span class="mi">3</span><span class="p">,</span> <span class="n">remove_trailing_nulls</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>

<span class="p">[</span><span class="s1">&#39;1&#39;</span><span class="p">,</span> <span class="s1">&#39;2&#39;</span><span class="p">,</span> <span class="s1">&#39;3&#39;</span><span class="p">]</span>  <span class="c1"># -&gt; [1, 2, 3]</span>
<span class="p">[</span><span class="s1">&#39;1&#39;</span><span class="p">,</span> <span class="s1">&#39;2&#39;</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">]</span>  <span class="c1"># -&gt; ValidationError - third entry required.</span>
<span class="p">[</span><span class="s1">&#39;1&#39;</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="s1">&#39;3&#39;</span><span class="p">]</span>  <span class="c1"># -&gt; ValidationError - second entry required.</span>
<span class="p">[</span><span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="s1">&#39;2&#39;</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">]</span>  <span class="c1"># -&gt; ValidationError - first and third entries required.</span>

<span class="n">SplitArrayField</span><span class="p">(</span><span class="n">IntegerField</span><span class="p">(</span><span class="n">required</span><span class="o">=</span><span class="kc">False</span><span class="p">),</span> <span class="n">size</span><span class="o">=</span><span class="mi">3</span><span class="p">,</span> <span class="n">remove_trailing_nulls</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>

<span class="p">[</span><span class="s1">&#39;1&#39;</span><span class="p">,</span> <span class="s1">&#39;2&#39;</span><span class="p">,</span> <span class="s1">&#39;3&#39;</span><span class="p">]</span>  <span class="c1"># -&gt; [1, 2, 3]</span>
<span class="p">[</span><span class="s1">&#39;1&#39;</span><span class="p">,</span> <span class="s1">&#39;2&#39;</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">]</span>  <span class="c1"># -&gt; [1, 2, None]</span>
<span class="p">[</span><span class="s1">&#39;1&#39;</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="s1">&#39;3&#39;</span><span class="p">]</span>  <span class="c1"># -&gt; [1, None, 3]</span>
<span class="p">[</span><span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="s1">&#39;2&#39;</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">]</span>  <span class="c1"># -&gt; [None, 2, None]</span>

<span class="n">SplitArrayField</span><span class="p">(</span><span class="n">IntegerField</span><span class="p">(</span><span class="n">required</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> <span class="n">size</span><span class="o">=</span><span class="mi">3</span><span class="p">,</span> <span class="n">remove_trailing_nulls</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>

<span class="p">[</span><span class="s1">&#39;1&#39;</span><span class="p">,</span> <span class="s1">&#39;2&#39;</span><span class="p">,</span> <span class="s1">&#39;3&#39;</span><span class="p">]</span>  <span class="c1"># -&gt; [1, 2, 3]</span>
<span class="p">[</span><span class="s1">&#39;1&#39;</span><span class="p">,</span> <span class="s1">&#39;2&#39;</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">]</span>  <span class="c1"># -&gt; [1, 2]</span>
<span class="p">[</span><span class="s1">&#39;1&#39;</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="s1">&#39;3&#39;</span><span class="p">]</span>  <span class="c1"># -&gt; ValidationError - second entry required.</span>
<span class="p">[</span><span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="s1">&#39;2&#39;</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">]</span>  <span class="c1"># -&gt; ValidationError - first entry required.</span>

<span class="n">SplitArrayField</span><span class="p">(</span><span class="n">IntegerField</span><span class="p">(</span><span class="n">required</span><span class="o">=</span><span class="kc">False</span><span class="p">),</span> <span class="n">size</span><span class="o">=</span><span class="mi">3</span><span class="p">,</span> <span class="n">remove_trailing_nulls</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>

<span class="p">[</span><span class="s1">&#39;1&#39;</span><span class="p">,</span> <span class="s1">&#39;2&#39;</span><span class="p">,</span> <span class="s1">&#39;3&#39;</span><span class="p">]</span>  <span class="c1"># -&gt; [1, 2, 3]</span>
<span class="p">[</span><span class="s1">&#39;1&#39;</span><span class="p">,</span> <span class="s1">&#39;2&#39;</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">]</span>  <span class="c1"># -&gt; [1, 2]</span>
<span class="p">[</span><span class="s1">&#39;1&#39;</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="s1">&#39;3&#39;</span><span class="p">]</span>  <span class="c1"># -&gt; [1, None, 3]</span>
<span class="p">[</span><span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="s1">&#39;2&#39;</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">]</span>  <span class="c1"># -&gt; [None, 2]</span>
</pre></div>
</div>
</dd></dl>

</dd></dl>

</div>
<div class="section" id="s-hstorefield">
<span id="hstorefield"></span><h3><code class="docutils literal notranslate"><span class="pre">HStoreField</span></code><a class="headerlink" href="#hstorefield" title="Permalink to this headline">¶</a></h3>
<dl class="class">
<dt id="django.contrib.postgres.forms.HStoreField">
<em class="property">class </em><code class="descname">HStoreField</code><a class="reference internal" href="../../../_modules/django/contrib/postgres/forms/hstore.html#HStoreField"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#django.contrib.postgres.forms.HStoreField" title="Permalink to this definition">¶</a></dt>
<dd><p>A field which accepts JSON encoded data for an
<a class="reference internal" href="fields.html#django.contrib.postgres.fields.HStoreField" title="django.contrib.postgres.fields.HStoreField"><code class="xref py py-class docutils literal notranslate"><span class="pre">HStoreField</span></code></a>. It casts all values
(except nulls) to strings. It is represented by an HTML <code class="docutils literal notranslate"><span class="pre">&lt;textarea&gt;</span></code>.</p>
<div class="admonition-user-friendly-forms admonition">
<p class="first admonition-title">User friendly forms</p>
<p class="last"><code class="docutils literal notranslate"><span class="pre">HStoreField</span></code> is not particularly user friendly in most cases,
however it is a useful way to format data from a client-side widget for
submission to the server.</p>
</div>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">On occasions it may be useful to require or restrict the keys which are
valid for a given field. This can be done using the
<a class="reference internal" href="validators.html#django.contrib.postgres.validators.KeysValidator" title="django.contrib.postgres.validators.KeysValidator"><code class="xref py py-class docutils literal notranslate"><span class="pre">KeysValidator</span></code></a>.</p>
</div>
<div class="versionchanged">
<span class="title">Changed in Django 1.11:</span> <p>Added the ability to store nulls.</p>
</div>
</dd></dl>

</div>
<div class="section" id="s-jsonfield">
<span id="jsonfield"></span><h3><code class="docutils literal notranslate"><span class="pre">JSONField</span></code><a class="headerlink" href="#jsonfield" title="Permalink to this headline">¶</a></h3>
<dl class="class">
<dt id="django.contrib.postgres.forms.JSONField">
<em class="property">class </em><code class="descname">JSONField</code><a class="reference internal" href="../../../_modules/django/contrib/postgres/forms/jsonb.html#JSONField"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#django.contrib.postgres.forms.JSONField" title="Permalink to this definition">¶</a></dt>
<dd><p>A field which accepts JSON encoded data for a
<a class="reference internal" href="fields.html#django.contrib.postgres.fields.JSONField" title="django.contrib.postgres.fields.JSONField"><code class="xref py py-class docutils literal notranslate"><span class="pre">JSONField</span></code></a>. It is represented by an
HTML <code class="docutils literal notranslate"><span class="pre">&lt;textarea&gt;</span></code>.</p>
<div class="admonition-user-friendly-forms admonition">
<p class="first admonition-title">User friendly forms</p>
<p class="last"><code class="docutils literal notranslate"><span class="pre">JSONField</span></code> is not particularly user friendly in most cases, however
it is a useful way to format data from a client-side widget for
submission to the server.</p>
</div>
</dd></dl>

</div>
<div class="section" id="s-range-fields">
<span id="range-fields"></span><h3>Range Fields<a class="headerlink" href="#range-fields" title="Permalink to this headline">¶</a></h3>
<p>This group of fields all share similar functionality for accepting range data.
They are based on <a class="reference internal" href="../../forms/fields.html#django.forms.MultiValueField" title="django.forms.MultiValueField"><code class="xref py py-class docutils literal notranslate"><span class="pre">MultiValueField</span></code></a>. They treat one
omitted value as an unbounded range. They also validate that the lower bound is
not greater than the upper bound. All of these fields use
<a class="reference internal" href="#django.contrib.postgres.forms.RangeWidget" title="django.contrib.postgres.forms.RangeWidget"><code class="xref py py-class docutils literal notranslate"><span class="pre">RangeWidget</span></code></a>.</p>
<div class="section" id="s-integerrangefield">
<span id="integerrangefield"></span><h4><code class="docutils literal notranslate"><span class="pre">IntegerRangeField</span></code><a class="headerlink" href="#integerrangefield" title="Permalink to this headline">¶</a></h4>
<dl class="class">
<dt id="django.contrib.postgres.forms.IntegerRangeField">
<em class="property">class </em><code class="descname">IntegerRangeField</code><a class="reference internal" href="../../../_modules/django/contrib/postgres/forms/ranges.html#IntegerRangeField"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#django.contrib.postgres.forms.IntegerRangeField" title="Permalink to this definition">¶</a></dt>
<dd><p>Based on <a class="reference internal" href="../../forms/fields.html#django.forms.IntegerField" title="django.forms.IntegerField"><code class="xref py py-class docutils literal notranslate"><span class="pre">IntegerField</span></code></a> and translates its input into
<a class="reference external" href="http://initd.org/psycopg/docs/extras.html#psycopg2.extras.NumericRange" title="(in Psycopg v2.8)"><code class="xref py py-class docutils literal notranslate"><span class="pre">NumericRange</span></code></a>. Default for
<a class="reference internal" href="fields.html#django.contrib.postgres.fields.IntegerRangeField" title="django.contrib.postgres.fields.IntegerRangeField"><code class="xref py py-class docutils literal notranslate"><span class="pre">IntegerRangeField</span></code></a> and
<a class="reference internal" href="fields.html#django.contrib.postgres.fields.BigIntegerRangeField" title="django.contrib.postgres.fields.BigIntegerRangeField"><code class="xref py py-class docutils literal notranslate"><span class="pre">BigIntegerRangeField</span></code></a>.</p>
</dd></dl>

</div>
<div class="section" id="s-floatrangefield">
<span id="floatrangefield"></span><h4><code class="docutils literal notranslate"><span class="pre">FloatRangeField</span></code><a class="headerlink" href="#floatrangefield" title="Permalink to this headline">¶</a></h4>
<dl class="class">
<dt id="django.contrib.postgres.forms.FloatRangeField">
<em class="property">class </em><code class="descname">FloatRangeField</code><a class="reference internal" href="../../../_modules/django/contrib/postgres/forms/ranges.html#FloatRangeField"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#django.contrib.postgres.forms.FloatRangeField" title="Permalink to this definition">¶</a></dt>
<dd><p>Based on <a class="reference internal" href="../../forms/fields.html#django.forms.FloatField" title="django.forms.FloatField"><code class="xref py py-class docutils literal notranslate"><span class="pre">FloatField</span></code></a> and translates its input into
<a class="reference external" href="http://initd.org/psycopg/docs/extras.html#psycopg2.extras.NumericRange" title="(in Psycopg v2.8)"><code class="xref py py-class docutils literal notranslate"><span class="pre">NumericRange</span></code></a>. Default for
<a class="reference internal" href="fields.html#django.contrib.postgres.fields.FloatRangeField" title="django.contrib.postgres.fields.FloatRangeField"><code class="xref py py-class docutils literal notranslate"><span class="pre">FloatRangeField</span></code></a>.</p>
</dd></dl>

</div>
<div class="section" id="s-datetimerangefield">
<span id="datetimerangefield"></span><h4><code class="docutils literal notranslate"><span class="pre">DateTimeRangeField</span></code><a class="headerlink" href="#datetimerangefield" title="Permalink to this headline">¶</a></h4>
<dl class="class">
<dt id="django.contrib.postgres.forms.DateTimeRangeField">
<em class="property">class </em><code class="descname">DateTimeRangeField</code><a class="reference internal" href="../../../_modules/django/contrib/postgres/forms/ranges.html#DateTimeRangeField"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#django.contrib.postgres.forms.DateTimeRangeField" title="Permalink to this definition">¶</a></dt>
<dd><p>Based on <a class="reference internal" href="../../forms/fields.html#django.forms.DateTimeField" title="django.forms.DateTimeField"><code class="xref py py-class docutils literal notranslate"><span class="pre">DateTimeField</span></code></a> and translates its input into
<a class="reference external" href="http://initd.org/psycopg/docs/extras.html#psycopg2.extras.DateTimeTZRange" title="(in Psycopg v2.8)"><code class="xref py py-class docutils literal notranslate"><span class="pre">DateTimeTZRange</span></code></a>. Default for
<a class="reference internal" href="fields.html#django.contrib.postgres.fields.DateTimeRangeField" title="django.contrib.postgres.fields.DateTimeRangeField"><code class="xref py py-class docutils literal notranslate"><span class="pre">DateTimeRangeField</span></code></a>.</p>
</dd></dl>

</div>
<div class="section" id="s-daterangefield">
<span id="daterangefield"></span><h4><code class="docutils literal notranslate"><span class="pre">DateRangeField</span></code><a class="headerlink" href="#daterangefield" title="Permalink to this headline">¶</a></h4>
<dl class="class">
<dt id="django.contrib.postgres.forms.DateRangeField">
<em class="property">class </em><code class="descname">DateRangeField</code><a class="reference internal" href="../../../_modules/django/contrib/postgres/forms/ranges.html#DateRangeField"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#django.contrib.postgres.forms.DateRangeField" title="Permalink to this definition">¶</a></dt>
<dd><p>Based on <a class="reference internal" href="../../forms/fields.html#django.forms.DateField" title="django.forms.DateField"><code class="xref py py-class docutils literal notranslate"><span class="pre">DateField</span></code></a> and translates its input into
<a class="reference external" href="http://initd.org/psycopg/docs/extras.html#psycopg2.extras.DateRange" title="(in Psycopg v2.8)"><code class="xref py py-class docutils literal notranslate"><span class="pre">DateRange</span></code></a>. Default for
<a class="reference internal" href="fields.html#django.contrib.postgres.fields.DateRangeField" title="django.contrib.postgres.fields.DateRangeField"><code class="xref py py-class docutils literal notranslate"><span class="pre">DateRangeField</span></code></a>.</p>
</dd></dl>

</div>
</div>
</div>
<div class="section" id="s-widgets">
<span id="widgets"></span><h2>Widgets<a class="headerlink" href="#widgets" title="Permalink to this headline">¶</a></h2>
<div class="section" id="s-rangewidget">
<span id="rangewidget"></span><h3><code class="docutils literal notranslate"><span class="pre">RangeWidget</span></code><a class="headerlink" href="#rangewidget" title="Permalink to this headline">¶</a></h3>
<dl class="class">
<dt id="django.contrib.postgres.forms.RangeWidget">
<em class="property">class </em><code class="descname">RangeWidget</code>(<em>base_widget</em>, <em>attrs=None</em>)<a class="headerlink" href="#django.contrib.postgres.forms.RangeWidget" title="Permalink to this definition">¶</a></dt>
<dd><p>Widget used by all of the range fields.
Based on <a class="reference internal" href="../../forms/widgets.html#django.forms.MultiWidget" title="django.forms.MultiWidget"><code class="xref py py-class docutils literal notranslate"><span class="pre">MultiWidget</span></code></a>.</p>
<p><a class="reference internal" href="#django.contrib.postgres.forms.RangeWidget" title="django.contrib.postgres.forms.RangeWidget"><code class="xref py py-class docutils literal notranslate"><span class="pre">RangeWidget</span></code></a> has one required argument:</p>
<dl class="attribute">
<dt id="django.contrib.postgres.forms.RangeWidget.base_widget">
<code class="descname">base_widget</code><a class="headerlink" href="#django.contrib.postgres.forms.RangeWidget.base_widget" title="Permalink to this definition">¶</a></dt>
<dd><p>A <a class="reference internal" href="#django.contrib.postgres.forms.RangeWidget" title="django.contrib.postgres.forms.RangeWidget"><code class="xref py py-class docutils literal notranslate"><span class="pre">RangeWidget</span></code></a> comprises a 2-tuple of <code class="docutils literal notranslate"><span class="pre">base_widget</span></code>.</p>
</dd></dl>

<dl class="method">
<dt id="django.contrib.postgres.forms.RangeWidget.decompress">
<code class="descname">decompress</code>(<em>value</em>)<a class="headerlink" href="#django.contrib.postgres.forms.RangeWidget.decompress" title="Permalink to this definition">¶</a></dt>
<dd><p>Takes a single “compressed” value of a field, for example a
<a class="reference internal" href="fields.html#django.contrib.postgres.fields.DateRangeField" title="django.contrib.postgres.fields.DateRangeField"><code class="xref py py-class docutils literal notranslate"><span class="pre">DateRangeField</span></code></a>,
and returns a tuple representing and lower and upper bound.</p>
</dd></dl>

</dd></dl>

</div>
</div>
</div>


          </div>
        </div>
      </div>
      
        
          <div class="yui-b" id="sidebar">
            
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
  <h3><a href="../../../contents.html">Table of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">PostgreSQL specific form fields and widgets</a><ul>
<li><a class="reference internal" href="#fields">Fields</a><ul>
<li><a class="reference internal" href="#simplearrayfield"><code class="docutils literal notranslate"><span class="pre">SimpleArrayField</span></code></a></li>
<li><a class="reference internal" href="#splitarrayfield"><code class="docutils literal notranslate"><span class="pre">SplitArrayField</span></code></a></li>
<li><a class="reference internal" href="#hstorefield"><code class="docutils literal notranslate"><span class="pre">HStoreField</span></code></a></li>
<li><a class="reference internal" href="#jsonfield"><code class="docutils literal notranslate"><span class="pre">JSONField</span></code></a></li>
<li><a class="reference internal" href="#range-fields">Range Fields</a><ul>
<li><a class="reference internal" href="#integerrangefield"><code class="docutils literal notranslate"><span class="pre">IntegerRangeField</span></code></a></li>
<li><a class="reference internal" href="#floatrangefield"><code class="docutils literal notranslate"><span class="pre">FloatRangeField</span></code></a></li>
<li><a class="reference internal" href="#datetimerangefield"><code class="docutils literal notranslate"><span class="pre">DateTimeRangeField</span></code></a></li>
<li><a class="reference internal" href="#daterangefield"><code class="docutils literal notranslate"><span class="pre">DateRangeField</span></code></a></li>
</ul>
</li>
</ul>
</li>
<li><a class="reference internal" href="#widgets">Widgets</a><ul>
<li><a class="reference internal" href="#rangewidget"><code class="docutils literal notranslate"><span class="pre">RangeWidget</span></code></a></li>
</ul>
</li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="fields.html"
                        title="previous chapter">PostgreSQL specific model fields</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="functions.html"
                        title="next chapter">PostgreSQL specific database functions</a></p>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="../../../_sources/ref/contrib/postgres/forms.txt"
            rel="nofollow">Show Source</a></li>
    </ul>
   </div>
<div id="searchbox" style="display: none" role="search">
  <h3>Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="../../../search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    </div>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
              <h3>Last update:</h3>
              <p class="topless">Jun 03, 2019</p>
          </div>
        
      
    </div>

    <div id="ft">
      <div class="nav">
    &laquo; <a href="fields.html" title="PostgreSQL specific model fields">previous</a>
     |
    <a href="../../index.html" title="API Reference" accesskey="U">up</a>
   |
    <a href="functions.html" title="PostgreSQL specific database functions">next</a> &raquo;</div>
    </div>
  </div>

      <div class="clearer"></div>
    </div>
  </body>
</html>